var detail = new Vue({
    el: "#detail",
    data() {
        return {
            services: services,
            // userInfo:'',
            bid:'',
            positionData:[],
            companyData:[],
            id:'',
            username:'',
            positionID:'',
        }
    },
    created () {
        // this.userInfo = LoginStatus();
        // if(this.userInfo==false)
        //     return false;
        // this.username = this.userInfo.name;
        this.bid = GetQueryString('bid');
        if(this.bid==null||this.bid==""){
            layerMsg("扫描错误！请重新扫描")
            setTimeout(function() {
                window.location.href="my-resume.html" ;
            },3000);
            return false;
        }
        this.id = GetQueryString('id')
        this.init();
        this.positionID = this.positionData.id
        // console.log(this.positionData.check)
    },
    methods:{
        init:function () {
            var that=this;
            $.ajax({
                url:that.services+"/user/position/"+this.id
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    console.log(res);
                    console.log(0);
                    var check = ApiLoginStatus(res)
                    if(check==false)
                        return false;
                    if(res.success){
                        that.positionData = res.data.position;
                        that.companyData = res.data.company
                    }
                }
            });
            var  companyFullName = that.companyData.fullName;
            var positionName = that.positionData.positionName;
            $.ajax({
                url:that.services+"/user/resume/delivery/list?page=1&limit=20&status=&companyFullName="+companyFullName+"&positionName="+positionName
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    var check = ApiLoginStatus(res)
                    if(check==false)
                        return false;
                    var obj = JSON.parse(res) 
                    if(obj.count>0){
                        that.positionData.check = true;
                    }else{
                        that.positionData.check = false;
                    }
                }
            });
        }
    }

    
});
function sendResume(){
    var resumeId;
    $.ajax({
        url:services+'/user/resume'
        ,type:"get"
        ,async:false
        ,xhrFields: {
            withCredentials: true
        }
        ,crossDomain: true
        ,success:function(res){
           resumeId = res.data.resume.id
        }
    });


    positionId = $("#positionSendID").val();
    url = services+"/user/resume/send"
    $.ajax({
        type: 'put', // 提交方式 get/post
        url: url, // 需要提交的 url
        contentType:"application/json;charset=utf-8",
        xhrFields: {
            withCredentials: true
        }
        ,crossDomain: true
        ,data:JSON.stringify({
            "resumeId":resumeId		
            ,"positionId":positionId
        }),
         success: function(res) {
            if(res.success){
                layerMsg(res.message);
                setTimeout(function() {
                    var _url = window.location.href;
                    console.log(_url)
                    if (isCompany == '1') {
                        window.location.href=_url ;
                    } 
                },3000);
            }else{
                layerMsg("投递失败")
                return false;
            }                
        },
    })

}